let str = 'str';

// union types

let numberOrString: number | string

numberOrString = 'abc';
numberOrString = 123

numberOrString.toString()

function  getLength1(input:string | number):number{
    const str = input as string
    if (str.length){
        return  str.length
    }else {
        const  number = input as number
        return number.toString().length
    }
}


function  getLength2(input:string | number):number{
   if (typeof input === 'string'){
       return input.length
   }else {
       return  input.toString().length
   }
}
